home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
-
- EXAMPLE2.C
-
- Written by Eric Jorgensen (1995)
-
- The is an example program to illustrate how to use Varmint's Audio
- Tools to play .mid files.
-
-
- **************************************************************************/
-
- #include "sound.h"
- #include <conio.h>
-
-
- void main(void)
- {
- int i;
- // You need a MIDI structure to
- // hold the data from the .mid file.
- MIDI far *song;
- // You will also need a character
- // string to catch any error
- // messages from LoadMidi().
- char errstring[100];
- // Lastly, you will need an
- // instruument definition to set
- // up FM voices.
- BYTE inst[11] =
- { 0x03,0x01,0x00,0x00,0xF3,0xE4,0x64,0x35,0x00,0x01,0x00}; // Harpsichord
-
- // In general, it is good to perform
- // all file access before settup
- // up the sound blaster.
- song = LoadMidi("bach.mid",errstring);
- if(!song) {
- printf("ERROR loading midi: %s\n",errstring);
- exit(1);
- }
- // Set up the sound blaster.
- if(!SBSetUp()) {
- printf("SB_Setup returned this error: %s \n",errname[sberr]);
- FreeMidi(song); // Free the Midi you just loaded.
- exit(1);
- }
-
- GoVarmint(); // Start up the sound Kernel.
-
- FMReset(); // Get the FM chip ready.
-
- for(i = 0; i < 9; i++) { // Initialize all the voices
- FMSetVolume(i,0); // Turn each voice off.
- FMSetVoice(i,inst); // Set each voice to a harpsichord.
- }
-
- midi_data = song; // Tell VAT which song to play.
- MidiCommand(v_play); // Start the music!
-
- printf("Press a key to quit.\n");
- getch();
-
- DropDeadVarmint(); // Stop the SB interrupt.
- SBCleanUp(); // Clean up sound stuff.
- FreeMidi(song); // Free our sond effect.
-
- }